package com.wg.generator.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 打印启动URL
 *
 * @author： lihc14
 **/
@Component
@Slf4j
public class ServerConfig implements ApplicationListener<WebServerInitializedEvent> {

    @Override
    public void onApplicationEvent(WebServerInitializedEvent event) {
        int serverPort = event.getWebServer().getPort();
        String serverPath = event.getApplicationContext().getApplicationName();
        log.info("项目启动成功！访问地址: http://{}:{}{}", "127.0.0.1", serverPort, serverPath);
    }

}
